Conversation
| bit$X....Preliminary <- NULL | ||
|
|
||
| # replace "." with "NA" | ||
| bit$Average.Permit.Price[bit$Average.Permit.Price=="."] <- NA |
There was a problem hiding this comment.
If you want to do this for the whole data frame, here's an alternative: df[df=="."] <- NA https://stackoverflow.com/questions/19503266/replace-all-particular-values-in-a-data-frame
There was a problem hiding this comment.
also, to make code more readable, it's generally good to put spaces around = or == (which I didn't do, oops!) http://style.tidyverse.org/
|
|
||
| # remove commas | ||
| bit$Resident.Interim.Permits.Issued <- gsub(",", "", bit$Resident.Interim.Permits.Issued) | ||
| bit$Resident.Interim.Permits.Issued <- gsub(",", "", bit$Resident.Interim.Permits.Issued) |
There was a problem hiding this comment.
here's one example alternative method:
df <- data.frame(x = c("a", "1,x", "b", "c"),
y = c("b,b", "a,", "b", "f"),
z = c("a", "a", "g,,fhj", "a"),
stringsAsFactors = FALSE)
sapply(df, function(col){gsub(",", "", col)})
This way returns your data frame as a matrix, so it's worth checking to make sure it doesn't mess anything else up. There are also tidyverse ways of doing things like this, but I'll leave that for you to explore :)
|
|
||
| # write and validate EML | ||
| write_eml(eml, eml_path) | ||
| eml_validate(eml_path) |
There was a problem hiding this comment.
generally better to eml_validate before you write_eml just so you don't overwrite your file with bad eml! So that'd be:
eml_validate(eml)
write_eml(eml, eml_path)
| a <- read.csv('/home/stao/my-sasap/114_commercial_crew/Commercial Crew data 2012-2016.csv', | ||
| header = T, | ||
| stringsAsFactors = F, | ||
| na.strings = c("", "Not Available")) |
There was a problem hiding this comment.
hmm it looks like na.strings solved the problem you had to deal with in the other file ("." --> NA)! Cool, I didn't know about this argument!
|
|
||
| # correct typos | ||
| typo <- which(a$Full.Name == ",ARL A. HIXSON") | ||
| a$Full.Name[typo] <- "CARL A. HIXSON" |
There was a problem hiding this comment.
If you want, I think it's also possible to do all this in one line (without which):
a$Full.Name[a$Full.Name == ",ARL A. HIXSON"] <- "CARL A. HIXSON"
It does get a little bit harder to read though, so you could go either way.
| eml@dataset@intellectualRights <- new('intellectualRights', | ||
| .Data = "CFEC retains intellectual property rights to data collected by or for CFEC. Any dissemination of the data must credit CFEC as the source, with a disclaimer that exonerates the department for errors or deficiencies in reproduction, subsequent analysis, or interpretation. Please see http://www.adfg.alaska.gov/index.cfm?adfg=home.copyright for further information.") | ||
|
|
||
| # change abstract |
There was a problem hiding this comment.
Tip: you can create "sections" in RStudio if you add ------ or ##### to your comments. See here for more info: https://support.rstudio.com/hc/en-us/articles/200484568-Code-Folding-and-Sections
|
@stao1 if you want to make some of these changes you can update your pull request with these instructions: https://github.com/NCEAS/data-processing#making-changes-to-your-contribution |
No description provided.